Before analysis, users should consider conducting finer-scale
filtering in order to clean the NestWatch dataset after running
nw.cleandata. This may include selecting certain species,
identifying specific nest phenology dates (ie. incubation should not
last longer than X days for species Y), or limiting nest attempts to a
certain geographic area.
Limiting the dataset to just a few species can easily be done using
the pipe (%>%). If you are unfamiliar with “piping”, see
the migritrr package. Below we will subset the
merged.data dataframe produced in the Intro vignette to
include only attempts for Carolina Wren (“carwre”) and Bewick’s Wren
(“bewwre”).
Spatial filters are a flexible way to limit data to a predefined
geographic area. A user may choose to limit an analysis to nesting
attempts within a single Bird
Conservation Region or a select number of states. Or one may choose
to clean likely misidentified species by using a rangemap filter. If
those identifying criteria are easily subset from the dataset, like
states and countries (via Subnational.Code), a user may
user subsetting rules to filter their data for analysis. If the criteria
not already subsettable, a spatial filter can be used.
As an example, we can first view a plot of where the nests in
wrens are located by species. We can use tmap
to produce an interactive map. Note: When plotting any spatial
data, please be careful to maintain the correct CRS (coordinate
reference system) by projecting unprojected data. We will be
utilizing the sf package to help create and transform our
spatial data. Here we will project the wrens data into the Lambert
Conformal Conic Projection, which is well suited for mapping areas in
the United States.
# Create a spatial object from nest data
nest_points <- sf::st_as_sf(wrens, coords = c("Longitude", "Latitude"), crs = 4326) # data is in WGS 84 (crs = 4326)
# Define desired CRS to project data to
proj <- "+proj=lcc +lon_0=-90 +lat_1=33 +lat_2=45" # PROJ.4 sting defining the projection
# Project the nest points into LCC projection
nest_points <- sf::st_transform(nest_points, crs = proj) # apply projection
# Map nets locations
library(tmap)
tmap_mode("view") # starts interactive plot
map <- tm_basemap("Esri.WorldGrayCanvas") + # define basemap
tm_shape(nest_points) + # add nest point data
tm_dots(col = "Species.Name") # color nests by species
# View the map
map